package hxy.dragon.spring.webflux.handler;

import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

/**
 * @author eric
 * @program spring-webflux
 * @description 相当于 RestController
 * @date 2020/3/21
 */
@Component
public class HelloWorldHandlerFunction implements HandlerFunction<ServerResponse> {
    @Override
    public Mono<ServerResponse> handle(ServerRequest request) {
        return ServerResponse.ok().body(BodyInserters.fromValue("Helll World!Web Flux"));
    }
}
